package P8;

import java.math.BigDecimal;
import java.util.Comparator;
public class Common {
	
	public static boolean isNum(String str){
        try {
            new BigDecimal(str);
            return true;
        } catch (Exception e) {
            return false;
        }
	}
	
	public static double pankouStrtoDouble(String str){
		
		try{
			
			
			if(str != null && !str.equals("")){
				str = str.replace("H", "");
				str = str.replace("C", "");
				str = str.replace("O", "");
				str = str.replace("U", "");
				str = str.replace(" ", "");
			}else{
				return -1;
			}
			
			
			if(str == null || str.equals("")){
				return -1;
			}else if(str.contains("/")){
				double r1 = Double.parseDouble(str.split("/")[0]);
				double r2 = Double.parseDouble(str.split("/")[1]);
				return (r1+r2)/2;
			}else{
				return  Double.parseDouble(str);
			}
			
		}catch(Exception e){
			e.printStackTrace();
			return -1;
		}
		
		
	}

}
